package com.ruoyi.system.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.SysUnionContentMapper;
import com.ruoyi.system.domain.SysUnionContent;
import com.ruoyi.system.service.ISysUnionContentService;

/**
 * union资源Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-09-26
 */
@Service
public class SysUnionContentServiceImpl implements ISysUnionContentService 
{
    @Autowired
    private SysUnionContentMapper sysUnionContentMapper;

    /**
     * 查询union资源
     * 
     * @param unioncontentId union资源主键
     * @return union资源
     */
    @Override
    public SysUnionContent selectSysUnionContentByUnioncontentId(Integer unioncontentId)
    {
        return sysUnionContentMapper.selectSysUnionContentByUnioncontentId(unioncontentId);
    }

    /**
     * 查询union资源列表
     * 
     * @param sysUnionContent union资源
     * @return union资源
     */
    @Override
    public List<SysUnionContent> selectSysUnionContentList(SysUnionContent sysUnionContent)
    {
        return sysUnionContentMapper.selectSysUnionContentList(sysUnionContent);
    }

    /**
     * 新增union资源
     * 
     * @param sysUnionContent union资源
     * @return 结果
     */
    @Override
    public int insertSysUnionContent(SysUnionContent sysUnionContent)
    {
        sysUnionContent.setCreateTime(DateUtils.getNowDate());
        return sysUnionContentMapper.insertSysUnionContent(sysUnionContent);
    }

    /**
     * 修改union资源
     * 
     * @param sysUnionContent union资源
     * @return 结果
     */
    @Override
    public int updateSysUnionContent(SysUnionContent sysUnionContent)
    {
        sysUnionContent.setUpdateTime(DateUtils.getNowDate());
        if (sysUnionContent.getFlag()!=null&&!(sysUnionContent.getFlag().trim().isEmpty())&&sysUnionContent.getFlag().trim().equals("copy")){
            sysUnionContent.setUnioncontentId(null);
            return sysUnionContentMapper.insertSysUnionContent(sysUnionContent);
        }else {
            return sysUnionContentMapper.updateSysUnionContent(sysUnionContent);
        }

    }

    /**
     * 批量删除union资源
     * 
     * @param unioncontentIds 需要删除的union资源主键
     * @return 结果
     */
    @Override
    public int deleteSysUnionContentByUnioncontentIds(Integer[] unioncontentIds)
    {
        return sysUnionContentMapper.deleteSysUnionContentByUnioncontentIds(unioncontentIds);
    }

    /**
     * 删除union资源信息
     * 
     * @param unioncontentId union资源主键
     * @return 结果
     */
    @Override
    public int deleteSysUnionContentByUnioncontentId(Integer unioncontentId)
    {
        return sysUnionContentMapper.deleteSysUnionContentByUnioncontentId(unioncontentId);
    }
}
